package com.orhon.smartcampus.modules.teacher.fetcher;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.orhon.smartcampus.modules.teacher.dao.QualificationsOptionsDao;
import com.orhon.smartcampus.modules.teacher.entity.QualificationsOptions;
import com.orhon.smartcampus.modules.teacher.gqlModel.GQLQualificationsOption;
import com.orhon.smartcampus.modules.teacher.mm.QualificationsOptionMapper;

import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;

@Component
public class QualificationsOptionsFetcher implements DataFetcher  {
	
	@Autowired
    QualificationsOptionsDao qualificationsOptionsDao;

    @Override
    public Object get(DataFetchingEnvironment env) throws Exception {
        int id = Integer.parseInt(env.getArgument("id").toString());

        String hql = "from QualificationsOptions where deleted_at = null and id = "+id;
        QualificationsOptions item =  qualificationsOptionsDao.findId(hql, null);
        if(item!=null) {
            GQLQualificationsOption mapEntity = QualificationsOptionMapper.MAPPER.mapEntity(item);
            return mapEntity;
        }
		return null;
        
    }
}
